package Algorithm.MoveZero;

public class RemoveElements {

    public static void main(String[] args) {

        int[] arr = {1,2,2,3,4,5,6,7};

        System.out.println(new RemoveElements().removeElement(arr, 2));
    }



    public int removeElement(int[] nums, int val) {
        int k = 0;
        for (int i = 0; i < nums.length; i++) {
            if (val != nums[i]) {
                nums[k] = nums[i];
                k++;
            }
        }
        return k;
    }

}
